/-boot
/-docs
/-editor
/-files
/-files-old
/-imports
/-layout
/-shell
/-storage ...
/-storage/attached ...
/-storage/attached/api
DetectStorage.ts
LoadStorage.ts
LoadStorageRecipient.ts
PropertiesByFullPath.ts
StorageAccess.ts
StorageDetect.ts
UpdateStorage.ts
/-storage/attached/dom
/-storage/attached/indexedDB ...
DetectStorage.ts
FileData.ts
LoadStorage.ts
MetadataData.ts
StorageAccess.ts
StorageDetect.ts
UpdateStorage.ts
functions.ts
/-storage/attached/localStorage
/-storage/attached/webSQL
/-tests
/-typings
Dom.ts
TypeScriptService.ts
functions.ts
ko.ts
nteapo.html
persistence.api.ts
persistence.ts
shell.ts
teapo.html
teapo.ts
try.html
try.js
xxxxxxxxxx
 
1
module teapo.storage.attached.indexedDB {
2
​
3
  export class StorageAccess implements attached.StorageAccess {
4
​
5
    constructor(private _db: IDBDatabase) {
6
    }
7
​
8
    update(
9
      byFullPath: PropertiesByFullPath,
10
      timestamp: number,
11
      callback: (error: Error) => void): void {
12
​
13
      var transaction = this._db.transaction(['files', 'metadata'], 'readwrite');
14
      transaction.onerror = (errorEvent) => callback(wrapErrorEvent(errorEvent, 'update: transaction'));
15
      var filesStore = transaction.objectStore('files');
16
      
17
      var outstandingRequests = 1;
18
​
19
      function oneError(errorEvent: ErrorEvent, moreDescription) {
20
        if (!outstandingRequests) return;
21
​
22
        outstandingRequests = 0;
23
        callback(wrapErrorEvent(errorEvent, moreDescription));
24
      }
25
​
26
      function oneCompleted() {
27
        if (!outstandingRequests) return;
28
​
29
        outstandingRequests--;
30
        callback(null);
31
      }
32
​
33
      for (var fullPath in byFullPath) if (byFullPath.hasOwnProperty(fullPath)) {
34
​
35
        var getFile = filesStore.get(fullPath);
36
        getFile.onerror = (errorEvent) => callback(wrapErrorEvent(errorEvent, 'update: objectStore(files).get(' + file + ')'));
37
        getFile.onsuccess = (event) => {
38
​
39
          var fileData: FileData = getFile.result || { path: fullPath, properties: {} };
40
​
41
          var properties = fileData.properties || (fileData.properties = {});
42
          properties[property] = value;
43
​
44
          var putFile = filesStore.put(fileData);
45
          putFile.onerror = (errorEvent) => callback(wrapErrorEvent(errorEvent, 'update: objectStore(files).get(' + file + ')-put(' + property + ',' + value + ')'));
46
          putFile.onsuccess = (event) =>
47
            this._updateEditedUTC(
48
              Date.now(),
49
              transaction,
50
              (errorEvent) => callback(wrapErrorEvent(errorEvent, 'update: _updateEditedUTC')));
51
        };
52
      }
53
​
54
    }
55
​
56
    read(
57
      fullPath: string,
58
      callback: (properties: { [property: string]: string; }) => void): void {
59
      // TODO: read stuff
60
    }
61
​
62
  }
63
​
64
  
65
}
41:31